﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace calculator
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入第一个数字：");
            double num1 = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("请输入第二个数字：");
            double num2 = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("请输入运算符（+、-、*、/）：");
            char operation = Convert.ToChar(Console.ReadLine());
            double result;
            switch (operation) {
                case '+':
                    result = num1 + num2;
                    break;
                case '-':
                    result = num1 - num2;
                    break;
                case '*':
                    result = num1 * num2;
                    break;
                case '/':
                    if (num2 != 0) {
                        result = num1 / num2;
                    }
                    else {
                        Console.WriteLine("除数不能为零，请重新输入。");
                        return;
                    }
                    break;
                default:
                    Console.WriteLine("无效的运算符，请重新输入。");
                    return;
            }
            Console.WriteLine($"{num1} {operation} {num2} = {result}");
        }
    }
}
